<template>
    <div style="width:80%;margin:0 auto;padding:20px 0">

        <h2>销毁申请单</h2>


        <el-row ref="queryForm">
            <el-col :span="24">
                <el-form ref="form" :model="form" label-width="120px">
                    <el-row>
                        <el-col :span="22" :xs="24">
                            <el-form-item label="">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    标 题
                                </span>
                                <el-input v-model="form.destroyName" type="textarea" :rows="3"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11" :xs="24">
                            <el-form-item label="">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    申请人
                                </span>
                                <treeselect v-model="form.destroyUserId" :options="deptUserOptions" :normalizer="normalizer"
                                    noResultsText="暂无数据" placeholder="请选择申请人" :disable-branch-nodes="true" />
                                <el-input type="hidden" v-model="form.destroyUser"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="11" :xs="24">
                            <el-form-item label="" prop="destroyDept">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    申请部门
                                </span>
                                <treeselect v-model="form.destroyDeptId" :options="deptOptions" noResultsText="暂无数据"
                                    placeholder="请选择申请部门" />
                                <el-input type="hidden" v-model="form.destroyDept"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11" :xs="24">
                            <el-form-item label="销毁日期" prop="destroyDate">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    销毁日期
                                </span>
                                <el-date-picker v-model="form.destroyDate" type="date" placeholder="请选择日期"
                                    format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="22" :xs="24">
                            <el-form-item label="备 注">
                                <el-input v-model="form.destroyRemark" type="textarea" :rows="3"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </el-col>
        </el-row>
        <el-row class="mb8" ref="refbut" style="width:90%;margin:0 auto">
            <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" @click="delTap">移除</el-button>
            </el-col>

        </el-row>
        <div class="tableData">
            <el-table :data="tableDataList" @selection-change="handleSelectionChange" border align="center"
                header-align="center" :loading="loading" :row-key="getRowKeys" lazy :load="load"
                :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" style="width: 96%" :height="height">
                <el-table-column type="selection" width="55" align="center" prop="ID" :selectable="checkboxSelect">
                </el-table-column>
                <el-table-column label="审批意见" width="200" align="center" v-if="istype == '3' || istype == '2'" fixed="left">
                    <template slot-scope="scope">
                        <el-radio-group v-model="scope.row.archiveAgreeStatus"
                            :disabled="istype == '3' || cloumnApproval || scope.row.archiveAgreeStatusCanEdit == '0'"
                            @change="chanageStatus(scope.row)" v-if="scope.row.isChildren != '1'">
                            <el-radio :label="'0'">不同意</el-radio>
                            <el-radio :label="'1'">同意</el-radio>
                        </el-radio-group>
                    </template>
                </el-table-column>
                <el-table-column width="60" align="center" label="操作" v-if="istype == '2'">
                    <template slot-scope="scope">
                        <el-button class="wenjianannniu" type="text" icon="el-icon-view" plain
                            @click="celldblclick(scope.row)"
                            v-hasPermi="['archive:archiveBorrow:archiveBorrowReceipt:detail']" size="mini"
                            title="查看详情"></el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="dh" label="档号" width="200" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="title" label="题名" width="200" align="center" :show-overflow-tooltip="true">
                    <!--<template slot-scope="scope">
                        <span>{{ scope.row.DA_TYPE == 'x' ? scope.row.XMMC : scope.row.TITLE }}</span>
                    </template>-->
                </el-table-column>
                <el-table-column prop="nd" label="年度" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="fileCount" label="件数" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="ys" label="页数" align="center" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="bgqx" label="保管期限" align="center" :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                        <span v-for="(i, idx) in dict.type.BGQX" :key="idx">
                            {{ scope.row.bgqx == i.value ? i.label : '' }}
                        </span>
                    </template>
                </el-table-column>
              <el-table-column prop="csczfs" label="初审处置方式" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                        <span >
                          {{ scope.row.csczfs == 1 ? '续存' : scope.row.csczfs == 2 ? '销毁' : '' }}
                        </span>
                </template>
              </el-table-column>
              <el-table-column prop="csczyj" label="初审处置意见" align="center" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="fsczfs" label="复审处置方式" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                        <span >
<!--                          {{ scope.row.fsczfs == 1 ? '续存' : scope.row.csczfs == 2 ? '销毁' : '' }}-->
                          {{ scope.row.fsczfs == 1 ? '续存' : '销毁' }}
                        </span>
                </template>
              </el-table-column>
              <el-table-column prop="fsczyj" label="复审处置意见" align="center" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="sdczfs" label="审定处置方式" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                        <span >
<!--                          {{ scope.row.sdczfs == 1 ? '续存' : scope.row.csczfs == 2 ? '销毁' : '' }}-->
                          {{ scope.row.sdczfs == 1 ? '续存' :  '销毁' }}
                        </span>
                </template>
              </el-table-column>
            </el-table>
        </div>


        <el-row style="width:90%;margin-top:20px" ref="queryForm" v-show="isShowInfo">
            <el-col :span="24">
                <el-form ref="form" :model="form" label-width="120px">
                    <el-row>
                        <el-col :span="18">
                            <el-form-item label="">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    审批意见：
                                </span>
                                <el-radio-group v-model="form.resource" :disabled="istype == '3'"
                                    @change="chanageAllStatus(form.resource)">
                                    <el-radio :label="1">全部同意</el-radio>
                                    <el-radio :label="0">全部不同意</el-radio>
                                    <el-radio :label="2">自定义</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="" v-hasPermi="['archive:archiveBorrow:nextAssignee']"
                                v-show="isShowApprover && istype != '3'">
                                <span slot="label">
                                    <em style="color:red"> * </em>
                                    下一节点审批人
                                </span>
                                <treeselect v-model="form.nextAssignee" :options="roleUserOptions" :normalizer="normalizer"
                                    noResultsText="暂无数据" placeholder="请选择审批人" :disable-branch-nodes="true"
                                    :disabled="istype == '3'" />
                            </el-form-item>
                            <el-form-item label="" v-show="isGetNextTaskOptionId">
                                <el-checkbox v-model="form.endProcess" :disabled="istype == '3'">办结流程</el-checkbox>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="18">
                            <el-form-item label="批 注：">
                                <el-input v-model="form.note" type="textarea" :rows="3"
                                    :disabled="istype == '3'"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="24" class="j_content margin_top">
                <el-button type="primary" size="medium" @click="submitTap" :disabled="istype == '3'">提交</el-button>
                <!--                <el-button size="medium">取消</el-button>-->
            </el-col>
        </el-row>
        <!--start  组件详情 -->
        <jianDetailsOpen v-if="jianDetailsOpen" :open="jianDetailsOpen" module="borrowReceipt" :celldbData="celldbData"
            @detailsHandleClose="detailsHandleClose">
        </jianDetailsOpen>
        <!--end 组件详情 -->
        <!-- start 组卷\项目详情 -->
        <juanDetailsOpen v-if="juanDetailsOpen" :open="juanDetailsOpen" :celldbData="celldbData" module="borrowReceipt"
            @detailsHandleClose="detailsHandleClose"></juanDetailsOpen>
        <!-- end 组卷\项目详情 -->

    </div>
</template>
<script>
import { deptTreeNoDateScope, getUserProfile } from "@/api/system/user";
import estimateTableHeight from '@/mixins/estimateTableHeight' //vue项目中element-tabel自动计算高度
import {
    changeAllArchiveState,
    delArchiveFormSave,
    deptUserTree,
    downloadPurchaseRecordForm,
    formDataSave,
    getArchiveInfo,
    getArchiveList,
    getRouterPath,
    getthbytreenodeHeaderList,
    roleUserTree,
    setArchiveProcessStatusByArchiveId,
    setBorrowProcessDownloadStatus,
    setBorrowProcessPrintStatus,
    submit, getNextTaskOptionId
} from "@/api/archive/archivalAppraisal/destructionWarehouseManagement/destructionApplicationForm.js" //档案整理接口
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import jianDetailsOpen from '@/components/componentsJianDetails/index.vue' //件详情
import juanDetailsOpen from '@/components/componentsJuanDetails/index.vue' //卷详情
import { getInfo } from "@/api/login";
import { getLastIndexOf } from "@/utils";
import { getRouters } from "@/api/menu";

export default {
    name: "借阅车",
    archive_Dicts: ['LYMD', 'BGQX', 'JYTS', 'STJSFJC'], // 利用目的字典项
    props: ["istype", "isShow", "roleUserList"],// <!--归档申请单 istype="1"   待办 istype="2"  已办istype="3" -->
    mixins: [estimateTableHeight], // 混入方法
    components: { Treeselect, jianDetailsOpen, juanDetailsOpen },
    data() {
        return {
            form: {
            },
            tableDataList: [],//申请单列表
            loading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,

            getRowKeys(row) {
                return row.ID;
            },
            expands: [],
            // 部门树选项
            deptOptions: [],
            cloumnApproval: false,
            // 人员树选项
            deptUserOptions: [],
            roleUserOptions: [],
            dengJiTime: "",
            isShowInfo: false,
            taskId: '',
            height: undefined,
            jianDetailsOpen: false,//件详情弹窗
            juanDetailsOpen: false,//卷详情弹窗
            chooseNextAssignee: false,
            chooseNextAssigneeByRoleKey: false,
            // 是否出现审批人
            isShowApprover: false,

            isGetNextTaskOptionId: false, // 办结流程  true显示 false不显示
        }

    },
    watch: {
        istype: {
            handler(valNew) {

            },
            immediate: true
        }
    },
    created() {
        getRouters().then(res => {
            this.routeList = res.data
        })
        this.getConfigKey("NEXT_ASSIGNEE_ROLE_KEY").then(response => {
            if (response.msg == '' || esponse.msg == 'null') {
                this.chooseNextAssignee = false
            } else {
                this.chooseNextAssignee = true
            }
        });
        this.getConfigKey("NEXT_ASSIGNEE_BY_ROLE_KEY").then(response => {
            if (response.msg == 'true') {
                this.chooseNextAssigneeByRoleKey = true
            } else {
                this.chooseNextAssigneeByRoleKey = false
            }
        });
        this.getDeptTreePost(); //归属部门树接口
        this.deptUserTreePost();//获取人员树接口

        if (this.istype == "1") {
            this.getArchiveList(); //申请单列表
            this.getUserProfile();
            this.height = '15vh'
            // 当前登录人
            getInfo().then(res => {
                this.$set(this.form, 'destroyUserId', res.user.userId)

                this.$set(this.form, 'destroyDeptId', res.user.deptId)
            })
        }



        //this.form.destroyDate = year + "-" + month + "-" + day;

        if (this.isShow == "true") {
            this.isShowInfo = true
        } else {
            this.isShowInfo = false
        }
    },
    filters: {
        formattedTime(value) {
            // 格式化日期，你可以使用任何适合你的格式
            const date = new Date(value);
            return date.toLocaleDateString(); // 返回格式化后的日期字符串
        },
    },
    methods: {
        init(val) {
            console.log("222222222")
            console.log(val, this.istype, "sdklfjklsdjfsdkljfklsdjfklsdjfklsdjf")

            this.taskId = val.id
            this.form = {}
            this.info = val
            this.processId = val.instanceId
            const menuId = this.$route.meta.menuId
            this.tableDataList = []

            if (this.istype == '2') {   //只有待办任务调用
                getNextTaskOptionId(this.taskId).then(res => {
                    console.log(res, "0000000000")
                    this.isGetNextTaskOptionId = res.data;
                })
            }

            this.deptUserTreePost();//获取人员树接口
            if (val.archiveVariables.length != 0) {
                this.tableDataList = val.archiveVariables
                for (let i = 0; i < val.archiveVariables.length; i++) {
                    this.tableDataList[i].hasChildren = true
                }
            }
            if (val.processVariables != null) {
                console.log(123, val.processVariables)
                this.reset()
                this.form.destroyName = val.processVariables.destroyName
                this.form.destroyUser = val.processVariables.destroyUser
                this.form.destroyUserId = val.processVariables.destroyUserId
                this.form.destroyDept = val.processVariables.destroyDept
                this.form.destroyDeptId = val.processVariables.destroyDeptId
                if (val.processVariables.destroyDate != undefined) {
                    this.form.destroyDate = this.processingTime(val.processVariables.destroyDate * 1);
                }
                this.form.destroyRemark = val.processVariables.destroyRemark
                console.log(this.form)
            }
            if (val.otherVariables != null) {
                getInfo().then(res => {
                    const userName = res.user.userName
                    var arr = val.otherVariables.activitList.filter(item => item.assignee == userName)
                    if (arr.length > 0) {
                        if (arr[0].isAgree.controlValue == '同意') {
                            this.$set(this.form, 'resource', 1)
                        } else {
                            this.$set(this.form, 'resource', 0)
                        }
                        let agreeFlag = true;
                        let notAgreeFlag = true;
                        for (let i = 0; i < this.tableDataList.length; i++) {
                            agreeFlag = this.tableDataList[i].archiveAgreeStatus == '1' && agreeFlag ? agreeFlag : false;
                            notAgreeFlag = this.tableDataList[i].archiveAgreeStatus == '0' && notAgreeFlag ? notAgreeFlag : false;
                        }
                        let controlVal = agreeFlag ? 1 : notAgreeFlag ? 0 : 2;
                        this.$set(this.form, 'resource', controlVal)
                        if (arr[0].comment != null || arr[0].comment != undefined) {
                            this.$set(this.form, 'note', arr[0].comment.controlValue)
                        }
                    }
                })
            }
        },
        reset() {
            this.form = {
                destryoName: undefined,
                destroyUser: undefined,
                destroyUserId: undefined,
                destroyDept: undefined,
                destroyDeptId: undefined,
                destroyDate: undefined,
                destroyRemark: undefined
            }
        },
        changeDownload() {
            if (this.istype == '2') {
                let formData = {
                    processId: this.processId,
                    allowDownload: this.form.allowDownload,
                    liyongfangshi: this.form.liyongfangshi,
                    downloadNum: this.form.downloadNum
                }
                this.info.processVariables.allowDownload = this.form.allowDownload
                this.info.processVariables.liyongfangshi = this.form.liyongfangshi
                this.info.processVariables.downloadNum = this.form.downloadNum
                setBorrowProcessDownloadStatus(formData).then(response => {
                    this.init(this.info)
                    this.$forceUpdate();
                });
            }
        },
        changePrint() {
            if (this.istype == '2') {
                let formData = {
                    processId: this.processId,
                    allowPrint: this.form.allowPrint,
                    printNum: this.form.printNum
                }
                this.info.processVariables.allowPrint = this.form.allowPrint
                this.info.processVariables.printNum = this.form.printNum
                setBorrowProcessPrintStatus(formData).then(response => {
                    this.init(this.info)
                    this.$forceUpdate();
                });
            }
        },
        getUserProfile() {
            getUserProfile().then(response => {
                console.log("33333333333333")
                /*this.$set(this.form, 'destroyUserId', response.data.userId)
                this.$set(this.form, 'destroyUser', response.data.userName)
                this.$set(this.form, 'destroyDeptId', response.data.deptId)
                this.$set(this.form, 'destroyDept', response.data.dept)*/
            });
        },
        processingTime(time) {
            const date = new Date(time);
            // 获取日期的年、月、日
            const year = date.getFullYear();
            const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1
            const day = String(date.getDate()).padStart(2, '0');
            // 构建日期时间字符串
            return `${year}-${month}-${day}`;
        },
        chanageAllStatus(resource) {
            console.log("4444444444")
            if (this.chooseNextAssigneeByRoleKey && resource == '1') {
                let agreeUserList = this.roleUserList.agreeUserList
                this.roleUserOptions = agreeUserList
            } else if (this.chooseNextAssigneeByRoleKey && resource == '0') {
                let notAgreeUserList = this.roleUserList.notAgreeUserList
                this.roleUserOptions = notAgreeUserList
            } else if (this.chooseNextAssigneeByRoleKey && resource == '2') {
                let otherUserList = this.roleUserList.otherUserList
                this.roleUserOptions = otherUserList
            }
            if (this.roleUserOptions == undefined || this.roleUserOptions.length == 0) {
                this.isShowApprover = false
            } else {
                this.isShowApprover = true
            }
            if (resource == '0' || resource == '1') {
                //TODO 新建接口批量修改
                changeAllArchiveState(this.processId, resource).then(resp => {
                    this.cloumnApproval = false;
                    for (let i = 0; i < this.tableDataList.length; i++) {
                        if (this.tableDataList[i].archiveAgreeStatusCanEdit != 0) {
                            this.tableDataList[i].archiveAgreeStatus = resource + '';
                        }
                    }
                    //this.init(this.info)
                    this.form.resource = resource;
                    this.cloumnApproval = true;
                    this.$forceUpdate();
                })
            } else if (resource == '2') {
                this.cloumnApproval = false;
                this.form.resource = resource;
                this.$forceUpdate();
            }

        },
        formattedTime(value) {
            // 格式化日期，你可以使用任何适合你的格式
            const date = new Date(value);
            return date.toLocaleDateString(); // 返回格式化后的日期字符串
        },

        /** 查询部门下拉树结构 */
        getDeptTreePost() {
            deptTreeNoDateScope().then(response => {
                this.deptOptions = response.data;
            });
        },

        /**获取人员树接口 */
        deptUserTreePost() {

            deptUserTree().then(response => {
                this.deptUserOptions = response.data;
                if (this.deptUserOptions != undefined) {
                    // 重命名树结构中的字段
                    this.deptUserOptions.forEach(node => {
                        this.appendUser(node);
                    });
                }

            });
            roleUserTree().then(response => {
                this.roleUserOptions = response.data;
                if (this.roleUserOptions != undefined) {
                    // 重命名树结构中的字段
                    this.roleUserOptions.forEach(node => {
                        this.appendUser(node);
                    });
                    this.isShowApprover = true
                } else {
                    this.isShowApprover = false
                }
                // console.log(this.roleUserOptions)
            });
        },
        appendUser(node) {
            if (node.children && node.children.length > 0) {
                node.children.forEach(child => {
                    this.appendUser(child);
                });
            }
            if (node.userChildren && node.userChildren.length > 0) {
                node.userChildren.forEach(user => {
                    user.nodeType = 'user'; // 添加 nodeType 属性
                });
                node.children = [...(node.children || []), ...node.userChildren];
                delete node.userChildren;
            }
        },
        normalizer(node) {
            // console.log(node)
            // console.log(node.children,"++111111111111111++")
            if (node.nodeType != 'user') {
                if (node.children == undefined) {
                    node["children"] = undefined
                    node['isDisabled'] = true;
                }
            }

        },

        // 多选框选中数据
        handleSelectionChange(selection) {
            console.log(selection)

            this.ids = selection.map(item => item.daId);
            this.single = selection.length != 1;
            this.multiple = !selection.length;
            this.onlyEorF = true;
            this.eFile = true;
            this.fFile = true;
            this.isBorrowed = false;
            for (let i = 0; i < selection.length; i++) {
                let item = selection[i]
                console.log(item)
                if (item.BORROW_TYPE == 'E') {
                    this.fFile = false;
                }
                if (item.BORROW_TYPE == 'F') {
                    this.eFile = false;
                    if (item.STJSFJC == 1) {
                        this.isBorrowed = true;
                    }
                }
            }
            this.onlyEorF = this.eFile || this.fFile;
        },
        getArchiveList() {
            this.loading = true;
            getArchiveList().then(res => {
                this.loading = false;
                const menuId = this.$route.meta.menuId
                if (res.code == "200" && res.rows != undefined) {
                    this.tableDataList = res.rows;
                    for (let i = 0; i < res.rows.length; i++) {
                        //this.tableDataList[i].hasChildren = true
                    }
                } else if (res.data == undefined) {
                    this.tableDataList = [];
                }
            })
        },
        // 懒加载表格数据
        load(tree, treeNode, resolve) {
            setTimeout(() => {
                var level = "";
                if (getLastIndexOf(tree.SUB_TABLE_NAME) == "F") {  //F 件
                    level = 'efile'
                } else if (getLastIndexOf(tree.SUB_TABLE_NAME) == "V") { //卷
                    level = 'jian'
                } else { //项目
                    level = 'juan'
                }
                const menuId = this.$route.meta.menuId
                const archiveId = tree.ID
                const categoryId = tree.CATEGORY_ID
                if (level != 'efile') {
                    getArchiveInfo(
                        {
                            menuId: menuId, level: level, archiveId: archiveId, categoryId: categoryId
                        }
                    ).then(response => {
                        for (let i = 0; i < response.rows.length; i++) {
                            response.rows[i].hasChildren = true
                            response.rows[i].isChildren = '1'
                        }
                        resolve(response.rows)
                    })
                } else {
                    resolve([])
                }
            }, 1000)
        },
        // 是否禁用多选框
        checkboxSelect(row) {
            if (row.isChildren == '1') {
                return false
            } else {
                return true
            }
        },
        delTap() {
            // console.log(this.multiple, this.single, ")))")
            if (this.multiple) {
                this.$message({ message: '请选择要移除的数据哦', type: 'warning' })
            } else {
                this.$modal.confirm('是否确认移除所选数据项？').then(() => {
                    console.log("delTap this.ids", this.ids)
                    delArchiveFormSave({
                        ids: this.ids.toString()
                    }).then(res => {
                        this.$modal.msgSuccess("删除成功");
                        this.getArchiveList();
                    })
                }).catch(() => { });

            }
        },
        //提交
        submitTap() {

               // 获取人员
      if (this.multiple && this.istype == "1") {
        this.$message({ message: '请选择要提交的数据哦', type: 'warning' })
        return;
      }

            // 获取人员
            const personnel = this.findNodeById(this.form.destroyUserId, this.deptUserOptions);
            if (personnel) {
                this.form.destroyUser = personnel.label
                this.form.destroyUserId = personnel.id
            }
            // 获取部门
            const department = this.findNodeById(this.form.destroyDeptId, this.deptOptions)
            if (department) {
                this.form.destroyDept = department.label
                this.form.destroyDeptId = department.id
            }

            if (this.form.destroyName == undefined || this.form.destroyName == null || this.form.destryoName == "") {
                this.$modal.msgError("标题不能为空");
                return;
            } else if (personnel == undefined || personnel == null || personnel == "") {
                this.$modal.msgError("申请人不能为空");
                return;
            } else if (department == undefined || department == null || department == "") {
                this.$modal.msgError("申请部门不能为空");
                return;
            } else if (this.form.destroyDate == undefined || this.form.destroyDate == null || this.form.destroyDate == "") {
                this.$modal.msgError("销毁日期不能为空");
                return;
            }
            /*this.form.destroyUser = personnel.label
            this.form.destroyUserId = personnel.id
            this.form.destroyDept = department.label
            this.form.destroyDeptId = department.id*/

            if (this.chooseNextAssignee && !this.form.endProcess && this.isShowApprover) {
                if (this.form.nextAssignee == undefined || this.form.nextAssignee == null || this.form.nextAssignee == '') {
                    this.$modal.msgError("请选择下一审批人");
                    return;
                }
            }
            // <!--归档申请单 istype="1"   待办 istype="2"  已办istype="3" -->
            /*if (this.istype == "1") {*/
            console.log(this.form)

            this.$modal.confirm('是否确认提交？').then(() => {
                submit(this.form).then(res => {
                    this.$modal.msgSuccess(res.msg)
                    if (res.code == 200) {
                        this.$modal.msgSuccess(res.msg)
                        //重置表单
                        this.reset()
                        this.getArchiveList()
                    } else {
                        this.$modal.msgError(res.msg)
                    }

                    /*getRouterPath({ path: 'archive/archiveBorrow/archiveBorrowReceipt/notQrocessed/index' }).then(res => {
                        if (res.data != undefined) {
                            this.$router.push({
                                path: res.data
                            });
                        } else {
                            this.$message({
                                message: '您还没开通权限哦',
                                type: 'warning'
                            });
                        }
                    })*/
                })
            }).catch(() => {
            });
            /*} else if (this.istype == '2') {
                if (this.form.resource == null || this.form.resource == undefined) {
                    this.$modal.msgWarning('请选择审批意见')
                    return;
                }
                let agreeFlag = true;
                let notAgreeFlag = true;
                let controlVal = 1;
                if (this.form.resource == '2') {
                    for (let i = 0; i < this.tableDataList.length; i++) {
                        if (this.tableDataList[i].archiveAgreeStatus == undefined || this.tableDataList[i].archiveAgreeStatus == '') {
                            this.$modal.msgWarning('请为所有数据选择审批意见')
                            return;
                        } else {
                            agreeFlag = this.tableDataList[i].archiveAgreeStatus == '1' && agreeFlag ? agreeFlag : false;
                            notAgreeFlag = this.tableDataList[i].archiveAgreeStatus == '0' && notAgreeFlag ? notAgreeFlag : false;
                        }
                    }
                    controlVal = agreeFlag ? 1 : notAgreeFlag ? 0 : 1;
                } else {
                    controlVal = this.form.resource;
                }

                var data = []
                if (this.form.endProcess == true) {
                    controlVal = 2;
                }
                data = [{
                    controlId: 'is_agree',
                    controlDefault: '不同意--__--同意--__--办结',
                    controlIsParam: 'i',
                    controlLable: '审批意见',
                    controlType: 'radio',
                    controlValue: controlVal
                }, {
                    controlId: "comment",
                    controlDefault: 'FormProperty_2ugo1se',
                    controlIsParam: 'f--!!null',
                    controlLable: '批注',
                    controlType: 'textarea',
                    controlValue: this.form.note
                }, {
                    controlId: "nextAssignee",
                    controlDefault: 'FormProperty_298545',
                    controlIsParam: 'f--!!null',
                    controlLable: '下一节点办理人',
                    controlType: 'input',
                    controlValue: this.form.nextAssignee
                }];
                data.id = this.taskId
                formDataSave(data).then(response => {
                    this.$modal.msgSuccess(response.msg)
                    this.$emit('close')
                })
                this.$emit('close')
            }*/
            /*his.getArchiveList();*/
        },
        findNodeById(id, nodes) {
            for (const node of nodes) {
                if (node.id == id) {
                    console.log("node", node)
                    return node;
                }
                if (node.children) {
                    const result = this.findNodeById(id, node.children);
                    if (result) {
                        console.log("result", result)
                        return result;
                    }
                }
            }
            return null;
        },
        detailsHandleClose() {
            this.jianDetailsOpen = false;
            this.juanDetailsOpen = false;
        },
        celldblclick(row) {
            console.log(row, '------------------')
            var label = "";
            var level = "";
            if (getLastIndexOf(row.SUB_TABLE_NAME) == "F") {  //F 件
                level = 0
                label = row.TITLE;
            } else if (getLastIndexOf(row.SUB_TABLE_NAME) == "V") { //卷
                level = 1
                label = row.TITLE;
            } else { //项目
                level = 3
                label = row.XMMC;
            }
            const menuId = this.$route.meta.menuId
            getthbytreenodeHeaderList(
                {
                    categoryId: row.CATEGORY_ID, menuId: menuId, subTableName: row.SUB_TABLE_NAME
                }
            ).then(response => {
                var tableHeaderList = response.rows
                this.celldbData = {
                    id: row.ID,
                    categoryId: row.CATEGORY_ID,
                    menuId: menuId,
                    sub_table_name: row.SUB_TABLE_NAME,
                    label: label,
                    level: level,
                    ifSub_table_name: row.SUB_TABLE_NAME,
                    isDel: "0",  //判断是回收站数据还是接收收据 isDel:1  回收站    isDel:0 //离线接收、档案接收、在线接收
                    tableHeaderList: tableHeaderList,
                    borrowId: this.info.processVariables.borrowId // 借阅单的id
                }
                this.$nextTick(() => {
                    if (getLastIndexOf(row.SUB_TABLE_NAME) == "F") {  //F 进入件详情
                        this.jianDetailsOpen = true;
                    } else { //进入卷详情 和项目详情
                        this.juanDetailsOpen = true
                    }
                })
            })
        },
        //隐藏展开箭头
        getRowClass(row) {
            if (row.row.children1 === undefined) {
                return 'row-expand-cover';
            }
            if (row.row.children1.children2 === undefined) {
                return 'row-expand-cover';
            }
        },
        chanageStatus(row) {
            this.form = {
                processId: this.processId,
                archiveId: row.ID,
                status: row.archiveAgreeStatus
            }
            setArchiveProcessStatusByArchiveId(this.form).then(response => {
                this.init(this.info)
                this.flag = true
                this.form.resource = 2;
                this.$forceUpdate();
            })
        },
        hasRoute(path, routeList) {
            !routeList && (routeList = this.routeList, console.log('执行'))
            for (let i = 0; i < routeList.length; i++) {
                if (routeList[i].path == path) {
                    // console.log(routeList[i].path, path, "shuju")
                    return true
                }
                if (routeList[i].children) {
                    let flag = this.hasRoute(path, routeList[i].children)
                    // console.log(path, routeList[i].children, "000")
                    if (flag) {
                        return flag
                    }
                }
            }
            return false
        },
    }
}
</script>
<style lang="scss" scoped>
h2 {
    display: block;
    text-align: center;
    line-height: 30px;
    font-size: 30px;
    font-weight: bold;
}

.j_content {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

.margin_top {
    margin-top: 20px
}

::v-deep .input-border input {
    border: 0 !important;
}

.tableData {
    overflow-y: auto;
    width: 90%;
    margin: 20px auto 0;
}

.wenjianannniu {
    font-size: 18px;
    margin-left: 2px;
}</style>
